package com.techm.smptest.activities;

import com.techm.smptest.R;
import com.techm.smptest.backend.Settings;
import com.techm.smptest.network.ConnectServer;
import com.techm.smptest.network.Request;
import com.techm.smptest.network.URLFetcher;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {
	Context context = this;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Settings.getSharedPreferences(context).edit()
				.putString(Settings.USERNAME, "smpAdmin")
				.putString(Settings.PASSWORD, "smp3master").commit();

		new AsyncTask<String, Integer, String>() {

			@Override
			protected String doInBackground(String... params) {
				// TODO Auto-generated method stub

				Request req = new Request();
				req.addPayloadRegister("blackberry");

				// ConnectServer server = new ConnectServer(
				// URLFetcher.getRegistration(), req.getXMLInString(),
				// Settings.getUserName(context),
				// Settings.getPassword(context));

				ConnectServer server = new ConnectServer(
						URLFetcher.getAuthTable(), "",
						Settings.getUserName(context),
						Settings.getPassword(context));
				server.GET();
				return server.getResponse();
			}

			@Override
			protected void onPostExecute(String result) {
				// TODO Auto-generated method stub

			}

		}.execute();

	}
}
